<template>
	<view>
	<u-tabbar :value="value4" :fixed="true" :placeholder="false" activeColor="red" :safeAreaInsetBottom="true">
	   <u-tabbar-item :text="item.text" :icon="item.icon" :key="index" v-for="(item, index) in list" @tap="push(index)"></u-tabbar-item>
	  </u-tabbar>
	  
	</view>
</template>

<script>
	 import { mapState, mapMutations } from 'vuex';
export default {
	data() {
		return {
			list: [
			    {
				
			     text: '首页',
			     pagePath: '/pages/index/index',
			     icon: 'account'
			    },
			    {
					
			     text: '专题',
			     pagePath: '/pages/topic/topic',
			     icon: 'account'
			    },
			    {
					
			     text: '分类',
			     pagePath: '/pages/category/category',
			     icon: 'photo'
			    },
			    {
					
			     text: '购物车',
			     pagePath: '/pages/cart/cart',
			     icon: 'play-right'
			    },
			    {
					
			     text: '我的',
			     pagePath: '/pages/user/user',
			     icon: 'account'
			    }
			   ]
		};
	},
	methods: {
		 ...mapMutations(['changevalue']),
		 push(index) {
		  uni.switchTab({
			  
		   url: this.list[index].pagePath
		   
		  });
		  // this.changevalue(e);
		  // console.log(index);
		 }
	},
	computed:{
		value4() {
		   return this.$store.state.tabindex;
		  }
		  
	}
};
</script>

<style></style>


<!-- 
 import { mapState, mapMutations } from 'vuex';
 
 value4() {
    return this.$store.state.tabindex;
   }
 ...mapMutations(['changevalue']),
   push(e) {
    uni.switchTab({
     url: this.list[e].pagePath
    });
    this.changevalue(e);
   }
  }-->